﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using Rookey.Frame.Operate.Base;
using Rookey.Frame.EntityBase;
using Rookey.Frame.Model.Sys;
using Rookey.Frame.Operate.Base.OperateHandle;
using Rookey.Frame.Model.EnumSpace;
using Rookey.Frame.Base;

namespace Rookey.Demo.Operate
{
    /// <summary>
    /// 自定义初始化
    /// </summary>
    public class InitOperate : InitFactory
    {
        /// <summary> 
        /// 自定义初始化
        /// </summary>
        public override void CustomerInit()
        {
            string errMsg = string.Empty;

            #region 供应商管理
            Sys_Menu purchaseMenu = CommonOperate.GetEntity<Sys_Menu>(x => x.Name == "供应商管理", string.Empty, out errMsg);
            if (purchaseMenu == null)
            {
                purchaseMenu = new Sys_Menu()
                {
                    Name = "供应商管理",
                    Display = "供应商管理",
                    IsValid = true,
                    IsLeaf = false,
                    Sort = 1
                };
                Guid purchaseMenuId = CommonOperate.OperateRecord<Sys_Menu>(purchaseMenu, ModelRecordOperateType.Add, out errMsg, null, false);

                Sys_Menu supplierInfoMenu = new Sys_Menu()
                {
                    Name = "供应商信息",
                    Display = "供应商信息",
                    Sys_ModuleId = SystemOperate.GetModuleIdByName("供应商信息"),
                    ParentId = purchaseMenuId,
                    IsValid = true,
                    IsLeaf = true,
                    Sort = 1
                };
                Guid supplierInfoMenuId = CommonOperate.OperateRecord<Sys_Menu>(supplierInfoMenu, ModelRecordOperateType.Add, out errMsg, null, false);

            }
            #endregion
        }

        /// <summary>
        /// 自定义应用程序结束事件
        /// </summary>
        /// <param name="application"></param>
        public override void App_End(System.Web.HttpApplication application)
        {
        }

        /// <summary>
        /// 自定义应用程序启动事件
        /// </summary>
        /// <param name="application"></param>
        public override void App_Start(System.Web.HttpApplicationState application)
        {
        }
    }
}
